package com.telnetnz.ticketdesk.bean;

import java.util.List;

import org.springframework.beans.BeanUtils;

import com.telnetnz.ticketdesk.bean.misc.OperationLogObject;
import com.telnetnz.ticketdesk.dao.entity.TemplateEntity;
import com.telnetnz.ticketdesk.service.OperationLogService;

public class Template extends TemplateEntity implements OperationLogObject
{
	private static final long serialVersionUID = -1529153442518577885L;

	public List<OperationLog> getOperationLogs()
	{
		return OperationLogService.getLogsByPageAndCondition(
				0, 
				10, 
				OperationLogService.ORDERBY_TIME, 
				0, 
				0L, 		// userId
				OperationLogService.OBJECT_TYPE_TEMPLATE, // objectType
				getId(), 
				null, 
				null, 
				null);
	}

	public static Template adapt(TemplateEntity entity)
	{
		if (entity == null)
			return null;
		Template bean = new Template();
		BeanUtils.copyProperties(entity, bean);
		return bean;
	}

	public TemplateEntity toEntity()
	{
		return this;
	}

	public String getObjectName() {
		return getName();
	}

	public String getObjectSummary() {
		return getName();
	}
}
